#include "LED/led.h"
#include "UART/uart.h"
#include "PLL/pll.h"
#include "PRINT/my_printf.h"
#include "VIC/vic_reg.h"
#include "INIT/init.h"
#include "EXTI/exti.h"
#include "TIMER/timer.h"
#include "SDIO/sdio.h"
#include "PUBLIC/test.h"
#include "PUBLIC/public.h"

extern int over_flag;

char *test_str = "123456789";

void delay(uint t){
    while(t--);
}



int main(){
    u32 fp, sp, lr, pc, t = 0;

    led_init();
    exti_init();
    timer0_init();
    // timer2_init();
    // print_cpsr();
    // print_PERIPHBASE();
    // print_val("SDMMCVLKENB", 0xC00C5000);
    // print_val("SDMMCCLKGEN0L", 0xC00C5004);

    // print_val("[0xC001027C]", 0xC001027C);

    // sdio0_init();

    __asm__(
        "mov %0, fp\n"
        "mov %1, sp\n"
        :"=r"(fp), "=r"(sp)
    );
    // printf("main fp:%x sp:%x\r\n", fp, sp);
    // printf("%x%x\r\n", fp, sp);
    // print_hex((u32)test_str);

    __asm__(
        // "mrc p15, 0, %0, c1, c0, 0\n"
        "mov %0, lr\n"
        "mov %1, pc\n"
        :"=r"(lr), "=r"(pc)
    );
    // printf("System Control Register: %x\r\n", val);     // SCTLR

    // print_hex(lr);
    // print_hex(pc);

    // my_putc('1');
    // my_putc('2');
    // my_putc('3');
    // my_putc('\r');
    // my_putc('\n');

    // find(&over_flag);

    while(1){

        led1_on();
        delay(20000000);
        led1_off();
        delay(20000000);

        if(++t < 10){
            printf("TCNTO0:[%x] %d\r\n", TCNTO0, t);
        }
    }

    return 0;
}
